package com.iv.durian.cloud.facade.support;

import com.iv.durian.cloud.Notice;
import com.iv.durian.cloud.facade.NoticeFacade;
import com.iv.durian.cloud.service.NoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class NoticeFacadeImpl implements NoticeFacade {

    @Autowired
    private NoticeService noticeService;

    @Override
    public Notice get(@PathVariable(name = "noticeId") Integer noticeId) {
        return noticeService.get(noticeId);
    }

    @Override
    public Notice get(@PathVariable(name = "lessionId") int lessionId) {
        return noticeService.get(lessionId);
    }

    @Override
    public void add(@RequestBody Notice notice) {
        noticeService.add(notice);
    }

    @Override
    public void update(@RequestBody Notice notice) {
        noticeService.update(notice);
    }

    @Override
    public int remove(@PathVariable(name = "noticeId") Integer noticeId) {
        return noticeService.remove(noticeId);
    }

    @Override
    public List<Notice> list(@RequestParam(value = "lessionId",required = false) Integer lessionId,
                             @RequestParam(value = "offset",required = false) Integer offset,
                             @RequestParam(value = "limit",required = false) Integer limit) {
        return noticeService.list(lessionId, offset, limit);
    }

    @Override
    public int count(@RequestBody Notice notice) {
        return noticeService.count(notice);
    }
}
